<!--
 * @title:
 * @Description:
 * @Author: JZT.饶慧勇
 * @Date: 2025-05-30 13:43:08
 * @LastEditors: JZT.饶慧勇
 * @LastEditTime: 2025-06-04 17:25:16
-->
<script lang="ts" setup>
import { useTheme } from '@/composables/theme/theme';
import { useTabbar } from '@/composables/useTabbar';

defineOptions({
  options: {
    addGlobalClass: true,
    virtualHost: true,
    styleIsolation: 'shared'
  }
});

const { themeVars, theme } = useTheme();

const { activeTabbar, getTabbarItemValue, setTabbarItemActive, tabbarList } = useTabbar();

function handleTabbarChange({ value }) {
  setTabbarItemActive(value);
  uni.switchTab({
    url: value
  });
}

onShow(() => {
  // #ifdef APP-PLUS
  uni.hideTabBar();
  // #endif
});
</script>

<template>
  <wd-config-provider :theme-vars="themeVars" custom-style="min-height: 100vh" :theme="theme">
    <wd-navbar
      :title="activeTabbar.title"
      safe-area-inset-top
      placeholder
      :fixed="true"
      :bordered="false"
      custom-style="background: #dfe2e5"
    />
    <slot />
    <wd-tabbar
      :model-value="activeTabbar.path"
      placeholder
      bordered
      safe-area-inset-bottom
      fixed
      @change="handleTabbarChange"
    >
      <wd-tabbar-item
        v-for="(item, index) in tabbarList"
        :key="index"
        :name="item.path"
        :value="getTabbarItemValue(item.path)"
        :title="item.title"
        :icon="item.icon"
      />
    </wd-tabbar>
    <wd-notify />
    <wd-toast />
    <wd-message-box />
    <privacy-popup />
  </wd-config-provider>
</template>
